package com.ec.server;

import com.ec.core.manage.AppFactory;

public class Server {
	public static void main(String[] args)
    {
		System.out.println("..............begin initialize system.............");
		com.ec.core.manage.AppFactory.getAppFactory();
/*.....................................test code here .........................................*/
		
//		AppFactory.getAppFactory().getCrmManage().getProductEntity().generateOrgCode(-1);
		
/*.....................................end test code...........................................*/
		int status = 0;
		Ice.Communicator ic = null;
		try {
			ic = Ice.Util.initialize(args);
			Ice.ObjectAdapter adapter =	ic.createObjectAdapterWithEndpoints("EasyCrmAdapter", "default -p 10000");
			Ice.Object object = new ProductServiceImpl();
			adapter.add(object,ic.stringToIdentity("EasyCrm"));
			adapter.activate();
			ic.waitForShutdown();
		} catch (Ice.LocalException e) {
			e.printStackTrace();
			status = 1;
		} catch (Exception e) {
			System.err.println(e.getMessage());
			status = 1;
		}
		if (ic != null) {
			try {
				ic.destroy();
			} catch (Exception e) {
				System.err.println(e.getMessage());
				status = 1;
			}
		}
		System.exit(status);
    }
}
